<html>
<head><meta charset="utf-8"><title>Adt&#x27;s Variant · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html">Adt&#x27;s Variant</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172652875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172652875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172652875">(Aug 07 2019 at 06:11)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.AdtDef.html#structfield.variants" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.AdtDef.html#structfield.variants">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.AdtDef.html#structfield.variants</a> says "if this is a struct or enum, there will be a single variant". is that correct? I thought this represents the N variants of an enum?</p>



<a name="172652953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172652953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172652953">(Aug 07 2019 at 06:13)</a>:</h4>
<p>relatedly, is there example code somewhere for how to get the list of field types out of a <code>Tuple</code>, or a struct? All I see is a bunch of subst stuff...</p>



<a name="172653006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172653006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172653006">(Aug 07 2019 at 06:14)</a>:</h4>
<p>the docs of the "recovered" field of a variant are also extremely informative... they literally say "Recovered?" <span aria-label="rofl" class="emoji emoji-1f923" role="img" title="rofl">:rofl:</span></p>



<a name="172653769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172653769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172653769">(Aug 07 2019 at 06:35)</a>:</h4>
<blockquote>
<p>relatedly, is there example code somewhere for how to get the list of field types out of a <code>Tuple</code>, or a struct? All I see is a bunch of subst stuff...</p>
</blockquote>
<p>ah, found something</p>



<a name="172653777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172653777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172653777">(Aug 07 2019 at 06:35)</a>:</h4>
<p>I might add a convenience method for tuples, this is not entirely trivial to discover</p>



<a name="172655770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172655770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172655770">(Aug 07 2019 at 07:25)</a>:</h4>
<p>I also read those docs and was confused; if you have time to make a docs PR that would be great</p>



<a name="172657967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172657967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172657967">(Aug 07 2019 at 08:08)</a>:</h4>
<p>I'll fix the <code>AdtDef</code> thing as part of my zeroed-lint</p>



<a name="172657975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172657975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172657975">(Aug 07 2019 at 08:08)</a>:</h4>
<p>I have no idea what the "recovered" field is or does so I cannot fix those docs</p>



<a name="172784787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172784787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172784787">(Aug 08 2019 at 17:27)</a>:</h4>
<p>If you check git blame and it's mine it's a marker that there were errors during parsing this type, so don't complain about things like being unsized or missing arguments</p>



<a name="172784808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172784808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172784808">(Aug 08 2019 at 17:27)</a>:</h4>
<p>But I'm fuzzy about the details and u try to have relevant comments when adding things like these</p>



<a name="172833433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Adt%27s%20Variant/near/172833433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Adt&#x27;s.20Variant.html#172833433">(Aug 09 2019 at 08:15)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> helped out and there is a more informative doc comment there now :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>